package com.iotimc.attendancesystem.util;

import java.io.OutputStream;

public class RootShellCmd {
    private OutputStream os;

    public final void exec(String cmd) {
        try {
            if (os == null) {
                os = Runtime.getRuntime().exec("su").getOutputStream();
            }
            os.write(cmd.getBytes());
            os.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public final void simulateKey(int keyCode) {
        exec("input keyevent " + keyCode + "\n");
    }
}